<template lang="html">
  <div class="makexiaoss">
    <div class="banner12">
      <label id="fanhui" @click="back"><img src="../../static/img/return1.png" alt=""></label>
      <label>小记</label>
      <span class="icon-shou1" v-show="like" @click="like1()"></span>
      <span class="icon-shou2" v-show="dislike" @click="dislike1()"></span>
      <router-link to='/fens'>
        <span class="icon-redo2"></span>
      </router-link>
    </div>
    <div class="maconten">
      <div class="time">
         {{ times }}
      </div>
      <label>地球 对流层</label>
      <img src="../../static/img/xiaoji.jpg" alt="">
      <label>摄影 | Kristopher Roller</label>
      <div class="con_text">
        <textarea name="name" rows="8" cols="40" maxlength="200" @input="descInput" v-model="desc">{{ desc }}</textarea>
      </div>

      <div class="auths">
        <label>{{ athous }}</label>
          <span>{{ remnant }}/200</span>
      </div>
      <!-- <div class="">
        {{ $route.params.item }}
      </div> -->
      <!-- <div id="bao">
        <button type="button" name="button">保存</button>
        <button type="button" name="button">返回</button>
      </div> -->
    </div>
  </div>
</template>

<script>
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
const day = new Date().getDate();
export default {
  data() {
    return {
      times: '',
      like: true,
      dislike: false,
      remnant: 200,
      adds:'',
      desc:'只有最不重要的人才会想着要搞砸一个事情，只是因为，搞砸本身能让他们觉得自己一时似乎很重要。',
      txtVal:'',
      athous:'胡适《大裂》',
      _id:''
    }
  },
  methods: {
    back() {
      // console.log(this.da);
      console.log('hjhjhj');
      if(this.like==false){
        // console.log(datapes);
        if(this.adds==true){
          console.log('增加');
          var datapes={
            userid:localStorage.getItem('userids'),
            xiaomess:this.desc
          }
          console.log(datapes);
          this.axios.post('http://10.0.156.247:8888/addmess', datapes, {
              headers: {
                'Content-Type': 'application/json'
              }
            })
            .then(function(response) {
              // console.log(response.config.data);
              var redata=JSON.parse(response.config.data);
              console.log(redata);
                history.back()
              // localStorage.setItem('username',redata.username);
              // localStorage.setItem('perphoto',redata.userphoto);
              // localStorage.setItem('perbackimg',redata.userbackimg);
            })
            .catch(function(error) {
              console.log(error);
              console.log('ciowu');
            })
        }else{
          console.log('xiugai');
          var datapes={
            userid:localStorage.getItem('userids'),
            xiaomess:this.desc,
            _id:this._id
          }
          console.log(datapes);
          this.axios.post('http://10.0.156.247:8888/xiumess', datapes, {
              headers: {
                'Content-Type': 'application/json'
              }
            })
            .then(function(response) {
              // console.log(response.config.data);
              var redata=JSON.parse(response.config.data);
              console.log(redata);
              console.log('hhahahhhjkm');
                history.back()
              // localStorage.setItem('username',redata.username);
              // localStorage.setItem('perphoto',redata.userphoto);
              // localStorage.setItem('perbackimg',redata.userbackimg);
            })
            .catch(function(error) {
              console.log(error);
            });
        }
        //  location.reload()
      }else{
        history.back()
      }

    },
    like1() {
      this.like = false;
      this.dislike = true;
    },
    dislike1() {
      this.like = true;
      this.dislike = false;
    },
    descInput() {
      this.txtVal = this.desc.length;
      this.remnant = 200 - this.txtVal;
      this.athous=localStorage.getItem('username');
    }
  },
  watch: {

  },
  created() {
    this.times = year + ' / ' + month + ' / ' + day;
    this.txtVal = this.desc.length;
    this.remnant = 200 - this.txtVal;
    this.desc = this.$route.query.item;
    this.adds=this.$route.query.adds;
    this._id=this.$route.query._id;
    console.log(this._id);
    // console.log(this.da);
  }
}
</script>
<style media="screen">
body {
  margin: 0;
  padding: 0;
}
</style>
<style lang="css" scoped>
*{
  margin:0;
  padding:0;
  color: black;
}

.makexiaoss{
  /*height: 700px;*/
  position: relative;
  /*background: linear-gradient(to bottom,#562e37,#f17c67);*/
  background:white;
  /*color: white;*/
  }

  .banner12{
    height: 2.5rem;
    /*background: white;*/
    line-height: 2.5rem;
    color: #646a58;
    font-size: 1.8rem;
    width: 100%;
    position:fixed;
    top: 0rem;
    left: 0;
    z-index: 100;
    background: white;
    margin-top: 0;
  }
  #fanhui{
    position: absolute;
    height: 1.5rem;
    width: 0.9rem;
    /*background-image: url(../../static/img/return1.png);
    background-size: 15px,15px;*/
    top: 0.3rem;
    left: 0.9rem;
  }
  #fanhui>img{
    height: 1.5rem;
    width: 0.8rem;
  }
  .icon-redo2:before {
    content: "\e968";
    position: absolute;
    height: 1.5rem;
    width: 0.9rem;
    top: 0.3rem;
    right: 1.2rem;
    color: gray;
  }
  .maconten{
    margin-top: 3.0rem;
    margin-bottom: 4.0rem;
  }
  .maconten label{
    height: 3.0rem;
    line-height: 3.0rem;
    font-size: 1.0rem;
  }
  textarea{
    border-radius: 5px;
    background: #f9f9f9;
    padding: 5px;
  }
  .maconten img{
    height: 220px;
    width: 100%;
  }
  /*#bao{
    height: 2.5rem;
    text-align: center;
  }
  #bao>button{
    border: none;
    background: none;
  }
  #bao>button:first-of-type{
    margin-right: 3rem;
  }*/
  .time{
    color: gray;
    font-size: 1.8rem;
  }
  .icon-shou1:before {
  content: "\e90b";
  color: #a0a0a0;
  position: absolute;
  height: 1.5rem;
  width: 0.9rem;
  top: 0.3rem;
  right: 4.2rem;
  font-size: 1.8rem;
  /*background: red;*/
  }
  .icon-shou2:before {
  content: "\e90c";
  color: #d81e06;
  position: absolute;
  height: 1.5rem;
  width: 0.9rem;
  font-size: 2.0rem;
  top: 0.3rem;
  right: 4.2rem;
  }
  .auths>label{
    float: left;
    margin-left: 3.5rem;
  }
  .auths>span{
    float: right;
    margin-right: 3.5rem;
    margin-top: 1.0rem;
  }
</style>
